import * as globalTypes from '../../../../mutation-types'
import callCenterConfig from '../../../../api/config/callCenter/outboundCallLine'

export const queryOutLine = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.queryOutLine(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateLine = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.updateLine(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const saveSmallNumDialLine = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.saveSmallNumDialLine(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
// 通话座席管理
export const refreshUser = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.refreshUser(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchUpdateUversion = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.batchUpdateUversion(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const exportAgentList = ({commit}, data) => {
  return callCenterConfig.exportAgentList(data)
    .then(
      response => {
        if (response.Succeed) {
          commit(globalTypes.SET_FILEDOWNLOAD, {path: response.path, isSession: true})
        }
      }
    ).catch(
      (e) => {
        console.log(e)
        // 'message.default_tips'
      }
    )
}
export const enableAgent = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.enableAgent(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const disableAgent = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.disableAgent(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const retrieveUsers = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.retrieveUsers(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchDisableAgent = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.batchDisableAgent(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchUpdateAgentNum = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.batchUpdateAgentNum(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchAddAgent = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.batchAddAgent(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const queryAgentMigration = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.queryAgentMigration(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const moveAgent = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.moveAgent(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateAgent = ({commit, state, rootState, dispatch}, data) => {
  return callCenterConfig.updateAgent(data)
    .then(response => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
